class lzu::login {

   $condor_pkg = [
      "condor",
      "condor-classads",
      "condor-kbdd",
      "condor-procd",
      "condor-python",
      "condor-external-libs",
     ]
  yumrepo { "condor":
    baseurl => "http://${mirrorserver}/yum/condor/9.0/el${operatingsystemmajrelease}/release",
    descr => "condor",
    enabled => 1,
    gpgcheck => 0,
    priority => 20,
    before   => Yumrepo['site'],
  } ->

  package { $condor_pkg:
              ensure  => installed,
              require => Yumrepo['site'],
  } ->
  #sysctl { "net.ipv4.ip_forward":
  #  ensure => present,
  #  value  => "1",
  #  target => "/etc/sysctl.d/ipforward.conf",
  #}->
  #firewall { '100 snat for network local':
  #  chain    => 'POSTROUTING',
  #  jump     => 'MASQUERADE',
  #  proto    => 'all',
  #  outiface => 'em2',
  #  source   => '192.168.0.0/16',
  #  table    => 'nat',
  #}->
  #firewall { '100 Forward':
  #  chain   => 'FORWARD',
  #  iniface => 'em1',
  #  action  => 'accept',
  #}->
  firewall { '000 accept all icmp requests':
    proto  => 'icmp',
    action => 'accept',
  }->
  firewall { '001 accept all to lo interface':
    proto   => 'all',
    iniface => 'lo',
    action  => 'accept',
  }->
  firewall { '002 reject local traffic not on loopback interface':
    iniface     => '! lo',
    proto       => 'all',
    destination => '127.0.0.1/8',
    action      => 'reject',
  }->
  firewall { '003 accept related established rules':
    proto  => 'all',
    state  => ['RELATED', 'ESTABLISHED'],
    action => 'accept',
  }->
  firewall { '100 allow sshaccess':
    dport  => [22],
    proto  => tcp,
    action => accept,
  }->
  firewall { '100 accept internal network':
    chain   => 'INPUT',
    proto   => 'all',
    source  => '192.168.0.0/16',
    action  => 'accept',
  }->
  firewall { '100 accept IHEP network':
    chain   => 'INPUT',
    proto   => 'all',
    source  => '202.122.32.0/19',
    action  => 'accept',
  }->
  firewall { '100 accept locaal network':
    chain   => 'INPUT',
    proto   => 'all',
    source  => '210.26.48.0/23',
    action  => 'accept',
  }->
  firewall { '999 drop all other requests':
    proto  => 'all',
    action => 'drop',
  }->
  #file {"/etc/condor/wrapper":
  #  ensure     =>  directory,
  #  mode       =>  '0755',
  #  owner      =>  'root',
  #  group      =>  'root',
  #} ->
  #file {"/etc/condor/wrapper/wrapper.sh":
  #  mode       =>  '0755',
  #  owner      =>  'root',
  #  group      =>  'root',
  #  source     =>  "puppet:///modules/${module_name}/wrapper.sh",
  #  notify   => Exec['refresh_condor_wn']
  #} ->
  file {"/etc/condor/config.d/01-common.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/01-common.conf",
    notify   => Exec['restart_condor_wn']
  } ->
  file {"/etc/condor/config.d/01-login.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/01-login.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/02-schedd.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/02-schedd.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/03-cm.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/03-cm.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/04-negotiator-group.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/04-negotiator-group.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  file {"/etc/condor/config.d/09-auth.conf":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/09-auth.conf",
    notify   => Exec['refresh_condor_wn']
  } ->
  service { 'condor':
    ensure     => 'running',
    enable     => true,
    hasrestart => true,
    hasstatus  => true,
  }
  exec {'restart_condor_wn':
    command      => "/sbin/service condor restart",
    refreshonly  => true
  }
  exec {'refresh_condor_wn':
    command      => "/usr/sbin/condor_reconfig",
    refreshonly  => true
  }
  file{"/root/bin/checkssh.sh":
    mode       =>  '755',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/checkssh.sh",
    require    =>  File['/root/bin'],
  }
  file{"/etc/hosts.allow":
    mode       =>  '644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/hosts.allow",
  }
}

